﻿using ComponentFactory.Krypton.Toolkit;
using EasyERP_View.FrmBase;
using EasyERP_View.FrmWares;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics.Eventing.Reader;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using WeifenLuo.WinFormsUI.Docking;

namespace EasyERP_View
{
    /// <summary>
    /// 菜单栏子窗体
    /// </summary>
    public partial class FrmMenu : DockContent
    {
        /// <summary>
        /// 构造函数
        /// </summary>
        public FrmMenu()
        {
            InitializeComponent();
        }

        #region 打开子窗体的方法
        /// <summary>
        /// 打开子窗体的方法
        /// </summary>
        /// <param name="frm">子窗体对象</param>
        /// <param name="sender">打开子窗体的控件</param>
        private static void OpenSubFrm(DockContent frm)
        {
            //遍历 DockContent 集合中所有的子窗体
            foreach (DockContent item in FrmMain.instance.dockPanelMain.Contents.Cast<DockContent>())
            {
                //判断窗体是否已经打开
                if (item.Name.Equals(frm.Name))
                {
                    //激活已经打开的窗体
                    item.Activate();
                    return;
                }
            }
            //打开子窗体
            frm.Show(FrmMain.instance.dockPanelMain);
        }
        #endregion

        /// <summary>
        /// 单击主代码事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void LblMajro_Click(object sender, EventArgs e)
        {
            //打开主代码窗体
            FrmMajor frmMajor = new FrmMajor();
            OpenSubFrm(frmMajor);
        }

        /// <summary>
        /// 单击子代码事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void LblMinor_Click(object sender, EventArgs e)
        {
            FrmMinor frmMinor = new FrmMinor();
            OpenSubFrm(frmMinor);
        }

        /// <summary>
        /// 单击往来单位事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void LblPB_Click(object sender, EventArgs e)
        {
            FrmPartner frmPartner = new FrmPartner();
            OpenSubFrm(frmPartner);
        }

        /// <summary>
        /// 单击税率事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void LblTax_Click(object sender, EventArgs e)
        {
            FrmTax frmTax = new FrmTax();
            OpenSubFrm(frmTax);
        }

        /// <summary>
        /// 单击人员信息事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void LblUser_Click(object sender, EventArgs e)
        {
            FrmUser frmUser = new FrmUser();
            OpenSubFrm(frmUser);
        }

        /// <summary>
        /// 单击商品信息事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void LblItem_Click(object sender, EventArgs e)
        {
            FrmItem frmItem = new FrmItem();
            OpenSubFrm(frmItem);
        }

        /// <summary>
        /// 单击往来单价事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void LblPrice_Click(object sender, EventArgs e)
        {
            FrmItemPrice frmItemPrice = new FrmItemPrice();
            OpenSubFrm(frmItemPrice);
        }
    }
}
